home *** CD-ROM | disk | FTP | other *** search
- /*
- * h2n_n2h.c
- *
- * Copyright (C) 1994 First Class Technology.
- */
-
- #include<stdio.h>
- #include<sys/param.h>
-
- #ifdef __BIG_ENDIAN__
- /************************************************
- * *
- ************************************************/
- unsigned long
- htonl (unsigned long hostlong)
- {
- return hostlong;
- }
-
- /************************************************
- * *
- ************************************************/
- unsigned short
- htons (unsigned short hostshort)
- {
- return hostshort;
- }
-
- /************************************************
- * *
- ************************************************/
- unsigned long
- ntohl (unsigned long netlong)
- {
- return netlong;
- }
-
- /************************************************
- * *
- ************************************************/
- unsigned short
- ntohs (unsigned short netshort)
- {
- return netshort;
- }
- #endif
-
- #ifdef __LITTLE_ENDIAN__
- /************************************************
- * *
- ************************************************/
- unsigned long
- htonl (unsigned long hostlong)
- {
- unsigned long result;
-
- result = (((hostlong & 0xff) << 24)
- | ((hostlong & 0xff00) << 8)
- | ((hostlong & 0xff0000) >> 8)
- | ((hostlong & 0xff000000) >> 24));
-
- return result;
- }
-
- /************************************************
- * *
- ************************************************/
- unsigned short
- htons (unsigned short hostshort)
- {
- return (hostshort >> 8) | (hostshort << 8);
- }
-
- /************************************************
- * *
- ************************************************/
- unsigned long
- ntohl (unsigned long netlong)
- {
- return htonl (netlong);
- }
-
- /************************************************
- * *
- ************************************************/
- unsigned short
- ntohs (unsigned short netshort)
- {
- return ntohl (netshort);
- }
- #endif
-